import Vue from 'vue';
// 1.引入第三方ui
import ElementUI from 'element-ui';
Vue.use(ElementUI);
import 'element-ui/lib/theme-chalk/index.css';
import '@/assets/css/reset.css'
// 2.引入axios
import axios from 'axios'
const instance = axios.create({
  baseURL:'http://cloud-music.pl-fe.cn'
})
const instaner = axios.create({
  baseURL:'http://127.0.0.1:7001'
})
Vue.prototype.$http = instance
Vue.prototype.$https = instaner
// 3.设置过滤器
Vue.filter("handleString", function (val) {
    if (val.length > 3) {
        val = val.slice(0,4) + "..."
    }
    return val;
})
// 4.播放插件
import APlayer from '@moefe/vue-aplayer';

Vue.use(APlayer, {
  defaultCover: 'https://github.com/u3u.png',
  productionTip: true,
});

//5.配置前端跨域访问cookie
import VueCookie from 'vue-cookie';
axios.defaults.withCredentials = true;
axios.defaults.crossDomain = true
Vue.use(VueCookie);

//6.时间转换
Vue.filter("handleTime",function(val){
  var minute = Math.floor(val/60000);
  var second = (val-(minute*60*1000))/1000
  var timer = "0"+minute +":" +Math.floor(second)
  return timer
})

//7.转化为万
Vue.filter("handleNum",function(val){
  var num = Math.ceil(val/10000)
  return num
})
//8.转字符串
Vue.filter("handleJoin",function(val){
  return val.join()
})